package zhuoer.adv1;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Birthday1 {
	public static void main(String[] args) throws ParseException {
		Date date = new Date();
		Scanner input = new Scanner(System.in);
		SimpleDateFormat sim = new SimpleDateFormat("MM-dd");
		Calendar ss = Calendar.getInstance();
		sim.setLenient(false);
		int year = ss.get(Calendar.YEAR);
		int month = ss.get(Calendar.MONTH) + 1;
		long a1 = ss.getTimeInMillis();
		int dd = ss.get(Calendar.DAY_OF_YEAR);
		int month1 = 0;
		int day1 = 0;
		int g = 0;
		try {
			System.out.println("请输入你的生日:");
			String a = input.next();
			date = sim.parse(a);
			month1 = date.getMonth() + 1;
			day1 = date.getDate();
		} catch (Exception e) {
			ss.set(2012, 1, 29);
			month1 = ss.get(Calendar.MONTH) + 1;
			day1 = ss.get(Calendar.DAY_OF_MONTH);
		}
		ss.set(year, month1 - 1, day1);
		long a2 = ss.getTimeInMillis();
		int f = 0;
		int w = (int) ((a2 - a1) / (24 * 60 * 60 * 1000));
		if (a1 > a2) {
			if (year % 4 == 0 && year % 400 != 0) {
				f = 366 - dd;
			} else {
				f = 365 - dd;
			}
			if (month1 == 2 && day1 == 29) {
				for (int i = year + 1;; i++) {
					if (i % 4 == 0 && i % 400 != 0) {

						System.out.println("还有" + (60 + f) + "天");
						return;
					} else {
						f += 365;
					}
				}
			} else {
				ss.set(year + 1, month1 - 1, day1);
				long a4 = ss.getTimeInMillis();
				int v = (int) ((a4 - a1) / (24 * 60 * 60 * 1000));
				System.out.println("还有" + v + "天");
				return;
			}
		} else {
			System.out.println("还有" + w + "天");
		}
	}
}
